package controllers;

import helpers.CrawlerHelper;
import helpers.CronHelper;
import helpers.ExampleHelper;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.*;

import models.AutoSite;
import models.Blog;
import models.MessageQueue;

import services.Blogger;




import com.google.gdata.client.GoogleService;
import com.google.gdata.client.blogger.BloggerService;
import com.google.gdata.data.*;
import com.google.gdata.util.*;

import data.AutoSiteData;
import data.BlogData;
import data.MessageQueueData;

@SuppressWarnings("serial")
public class CrawlerLastestNews extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		response.setContentType("text/plain");
		
		String siteId = (String) request.getParameter("siteId");
		if (siteId != null && !siteId.isEmpty()) {
			//Get lastest news
			ArrayList<String> lastestNews = CronHelper.cronLastestNews(siteId);
			for (int i = 0; i < lastestNews.size(); i++) {
				response.getWriter().println(lastestNews.get(i));
			}
		}
	}
}

